package com.larry.rabbitmq.second;

import com.larry.rabbitmq.util.RabbitMQUtils;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

/**
 * @author larry
 * @Title: larry-rabbitmq
 * @Package com.larry.rabbitmq.second
 * @Description: 发送大量消息
 * @date 6/28/216:48 PM
 */
public class Task01 {
    public static final String QUEUE_NAME = "hello";

    public static void main(String args[]) throws Exception{
        Channel channel = RabbitMQUtils.getChannel();
        channel.queueDeclare(QUEUE_NAME,false,false,false,null);

        //从控制台中接收信息并发送
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String message = scanner.next();
            channel.basicPublish("",QUEUE_NAME,null,message.getBytes());
            System.out.println("发送完成: " + message);
        }

    }
}
